<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>结算单管理</title>
    <#include "/common/link.ftl">
    <script>
        $(function () {
            // 日期高级查询应该用让用户选择
            $('.input-date').datepicker({
                format: 'yyyy-mm-dd', //格式
                language: 'zh-CN', //中文
                autoclose: true,//选择后自动关闭
                //showMeridian:true, //是否显示上下午
                minView: 2,//精确到哪位
            });

            // 添加按钮
            $('.btn-input').click(function () {
                Swal.fire({
                    title: "温馨提示",
                    text: "未选定任何预约单,是否需要关联预约单?",
                    icon: 'warning',
                    showCancelButton: true,
                    confirmButtonColor: '#3085d6',
                    cancelButtonColor: '#d33',
                    confirmButtonText: '去关联',
                    cancelButtonText: '不关联'
                }).then((result) => {
                    if (result.value) {
                        // 去关联,则跳转到预约单列表页面
                        window.location.href = "/appointment/list";
                    } else {
                        // 不关联,则直接生成结算单
                        window.location.href = "/consumption/input";
                    }
                });

            });
        });
    </script>
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="consumption"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>结算单管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 20px 0px 0px 10px">
                    <form class="form-inline" id="searchForm" action="/consumption/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label>结算单状态</label>
                            <select class="form-control status" name="status">
                                <option value="-1">全部</option>
                                <option value="0">待结算</option>
                                <option value="1">待审核</option>
                                <option value="2">归档</option>
                                <option value="3">坏账</option>
                            </select>
                        </div>
                        <script>
                            $('.status').val('${qo.status}')
                        </script>
                        <div class="form-group">
                            <label>门店查询</label>
                            <select class="form-control business" name="businessId">
                                <option value="-1">请选择门店</option>
                                <#list businesses as b>
                                    <option value="${b.id}">${b.name}</option>
                                </#list>
                            </select>
                        </div>
                        <script>
                            $('.business').val('${qo.businessId}')
                        </script>
                        <#-- <div class="form-group">
                             <label>预约类型</label>
                             <select class="form-control" name="">
                                 <option value="">请选择预约类型</option>
                                 <option value="1">预约</option>
                                 <option value="0">非预约</option>
                             </select>
                         </div>-->

                        <div class="form-group">
                            <label>客户名称</label>
                            <input type="text" class="form-control" name="customerName" value="${qo.customerName}"
                                   placeholder="请输入客户名称">
                        </div>

                        <div class="form-group">
                            <label>客户手机号</label>
                            <input type="text" class="form-control" name="customerTel" value="${qo.customerTel}"
                                   placeholder="请输入客户手机号">
                        </div>
                        <div class="form-group">
                            <label>预约单流水号</label>
                            <input type="text" class="form-control" name="appointmentAno" value="${qo.appointmentAno}"
                                   placeholder="请输入预约单流水号">
                        </div>
                        <br/>
                        <br/>

                        <div class="form-group">
                            <label>结算单流水号</label>
                            <input type="text" class="form-control" name="cno" value="${qo.cno}"
                                   placeholder="请输入结算单流水号">
                        </div>

                        <div class="form-group">
                            <label>结算时间查询：</label>
                            <input placeholder="请输入开始时间" type="text" class="form-control input-date"
                                   name="beginDate" autocomplete="off" value="${(qo.beginDate?string('yyyy-MM-dd'))!}"
                            /> -
                            <input placeholder="请输入结束时间" type="text" class="form-control input-date"
                                   name="endDate" autocomplete="off" value="${(qo.endDate?string('yyyy-MM-dd'))!}"
                            />
                        </div>

                        <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>
                            查询
                        </button>
                        <a href="javascript:;" class="btn btn-success btn-input">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                    </form>

                </div>
                <div class="box-body table-responsive ">
                    <table class="table table-hover table-bordered table-striped">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>流水号</th>
                            <th>预约单号</th>
                            <th>客户名称</th>
                            <th>联系方式</th>
                            <th>总消费金额</th>
                            <th>实收金额</th>
                            <th>结算时间</th>
                            <th>结算人</th>
                            <th>消费门店</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <#list pageInfo.list as c>
                            <tr>
                                <td>${c_index + 1}</td>
                                <td>${c.cno!}</td>
                                <td>${c.appointmentAno!}</td>
                                <td>${c.customerName!}</td>
                                <td>${c.customerTel!}</td>
                                <td>${c.totalAmount!}</td>
                                <td>${c.payAmount!}</td>
                                <td>${(c.payTime?string("yyyy-MM-dd"))!}</td>
                                <td>${c.employee.name!}</td>
                                <td>${c.business.name!}</td>
                                <td>${c.statusDisplay!}</td>
                                <td>
                                    <a href="/consumption/input?id=${c.id}" class="btn btn-info btn-xs btn-detail">
                                        <span class="glyphicon glyphicon-pencil"></span> 详情
                                    </a>
                                </td>
                            </tr>
                        </#list>
                        </tbody>
                    </table>
                    <!--分页-->
                    <#include "/common/page.ftl">
                </div>

            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>

</body>
</html>